/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.edu.kamai.webservice;

import com.edu.kamai.logic.facade.ContestFacade;
import com.edu.kamai.persistence.beans.Contest;
import java.util.Date;
import java.util.List;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;

/**
 *
 * @author xyzhu
 */
@WebService(serviceName = "contestService")
@Stateless()
public class contestService {

    /**
     * Web 服务操作
     */
    @WebMethod(operationName = "addContest")
    public Integer addContest(@WebParam(name = "cTitle")
    String cTitle, @WebParam(name = "cDesc")
    String cDesc, @WebParam(name = "uID")
    String uID, @WebParam(name = "rID")
    int rID, @WebParam(name = "lID")
    int lID, @WebParam(name = "sID")
    int sID, @WebParam(name = "wID")
    int wID) {
        
        Contest contestBean = new Contest();
        contestBean.setTitle(cTitle);
        contestBean.setDescription(cDesc);
        contestBean.setStartTime(new Date());
        contestBean.setEndTime(null);
        contestBean.setUserId(uID);
        contestBean.setListeningId(lID);
        contestBean.setSpeakingId(sID);
        contestBean.setWritingId(wID);
        contestBean.setReadingId(rID);
        
        try{
            return ContestFacade.addContest(contestBean);
        }catch(Exception ex){
            ex.printStackTrace();
        }
        
        return 0;
    }

    /**
     * Web 服务操作
     */
    @WebMethod(operationName = "findContest")
    public List<Contest> findContest() {
        //TODO write your implementation code here:
        return ContestFacade.findContest();
    }

    /**
     * Web 服务操作
     */
    @WebMethod(operationName = "findContestByID")
    public Contest findContestByID(@WebParam(name = "cid")
    int cid) {
        //TODO write your implementation code here:
        return ContestFacade.findContestByID(cid);
    }
    
    
}
